﻿/**
 *  
 * @file   FITKCalculiXINPIOInterface.h
 * @brief  calculix的INP文件读取接口
 * @author XuChao (xxu715737@163.com)
 * @date   2024-06-04
 *
 */
#ifndef  __FITKCALCULIXINPIO_INTERFACE_H__
#define  __FITKCALCULIXINPIO_INTERFACE_H__

#include <QObject>
#include "FITKCalculiXInpIOAPI.h"
#include "FITK_Kernel/FITKCore/FITKCoreMacros.h"
#include "FITK_Kernel/FITKCore/FITKAbstractObjectContainer.hpp"
#include "FITK_Kernel/FITKAppFramework/FITKComponentInterface.h"

ForwardDeclarNS(Core, FITKAbstractDataObject);
ForwardDeclarNS(Interface, FITKAbstractIO);

namespace IO
{ 
    class FITKCCXInpIOAPI FITKCalculiXINPIO : public QObject,public AppFrame::FITKComponentInterface
    {
        Q_OBJECT
    public:
        using AppFrame::FITKComponentInterface::FITKComponentInterface;
        virtual ~FITKCalculiXINPIO() = default;

         
        /**
         * @brief 设置文件名称
         * @param fileName 文件名称
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-03-15
         */
        void setFileName(const QString& fileName);

        /**
        * @brief 获取部件名称，不能重复  return "CalculiXINPIO"
        * @return QString
        * @author LiBaojun (libaojunqd@foxmail.com)
        * @date 2024-03-04
        */
        virtual QString getComponentName() override;

        /**
         * @brief 文件读写时的数据对象
         * @param dataObject 数据对象
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-03-07
         */
        void setDataObject(Core::FITKAbstractDataObject* dataObject);

        /**
         * @brief 执行读取或写出
         * @param indexPort  1：读取 2：写出
         * @return
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-03-07
         */
        virtual bool exec(const int indexPort) override;
        /**
         * @brief 获取是否执行成功标记
         * @return bool
         * @author libaojun (libaojunqd@foxmail.com)
         * @date 2024-03-25
         */
        bool isSuccess();

        /**
         * @brief 是否在执行中
         * @return true 执行中 false未在执行
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-04-12
         */
        bool isRunning();
        /**
        * @brief 设置是否在独立的线程运行。默认true，为在独立线程执行
        * @param r 是否在独立线程运行
        * @author LiBaojun (libaojunqd@foxmail.com)
        * @date 2024-05-11
        */
        void setRunInThread(bool r = true);

    signals:
        /**
        * @brief 读取线程结束发送信号
        * @author LiBaojun (libaojunqd@foxmail.com)
        * @date 2024-03-04
        */
        void ioThreadFinishedSig();

    private slots:
        /**
       * @brief 读取线程结束处理槽函数
       * @author LiBaojun (libaojunqd@foxmail.com)
       * @date 2024-03-04
       */
        void ioThreadFinishedSlot();

    private:
        /**
        * @brief 文件名
        * @author fulipeng (fulipengqd@yeah.net)
        * @date 2024-03-07
        */
        QString _fileName{};

        /**
         * @brief 数据对象
         * @author fulipeng (fulipengqd@yeah.net)
         * @date 2024-03-07
         */
        Core::FITKAbstractDataObject* _dataObject{};
 
        /**
         * @brief 是否执行成功标记
         * @author libaojun (libaojunqd@foxmail.com)
         * @date 2024-03-25
         */
        bool _success{ false };
        /**
       * @brief 读写线程
       * @author LiBaojun (libaojunqd@foxmail.com)
       * @date 2024-03-04
       */
        Core::FITKAbstractObjectContainer<Interface::FITKAbstractIO> _io{nullptr};
        /**
       * @brief 是否在线程运行
       * @author LiBaojun (libaojunqd@foxmail.com)
       * @date 2024-03-04
       */
        bool _runInThread{ true };
    };
}
#endif // 